package com.stock.stockana.ui.activities;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;

import com.stock.publiclib.BaseActivity;
import com.stock.stockana.R;
import com.stock.stockana.ui.fragments.SettingFragment;
import com.stock.stockana.ui.fragments.VersionNoticeFragment;

import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

/**
 * ---------------------------------------------------
 * Description:
 * Author: ljgsonx
 * Belong to: com.stock.stockana.ui.activities
 * Time: 2016/3/17 10:12
 * ---------------------------------------------------
 */
public class SettingActivity extends BaseActivity {

    private static final String TAG = "VersionNoticeActivity->";

    private SettingFragment settingFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        settingFragment = new SettingFragment();
        addFragment(settingFragment);
        setToolbarPosTitle("基本设置");
        removeToolbarMenu();
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            onBackPressed();
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onBackPressed() {
        if (getSupportFragmentManager().getBackStackEntryCount() > 1) {
            getSupportFragmentManager().popBackStackImmediate();
        } else {
            finish();
            overridePendingTransition(R.anim.in_from_left, R.anim.out_from_right);
            if (MainActivity.instance == null) {
                startActivity(new Intent(this, MainActivity.class));
            }
        }
    }

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
    }


}
